package com.innovation.sys.common.utils;

import java.io.File;
import java.io.IOException;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class FileUtils {

	private static Logger logger = LoggerFactory.getLogger(FileUtils.class);

	// 判断文件是否存在，不存在则创建
	public static File createFile(String fileName) {
		File file = new File(fileName);
		if (!file.exists()) {
			try {
				file.createNewFile();
				return file;
			} catch (IOException e) {
				logger.info("error:{}" ,e);
			}
		} else {
			logger.info("文件已存在!");
			return file;
		}
		return null;
	}

	public static void isExistFolder(String directory) {
		File folder = new File(directory);
		if (!folder.exists() && !folder.isDirectory()) {
			folder.mkdirs();
			logger.info("创建文件夹!");
		} else {
			logger.info("文件夹已存在!");
		}
	}

}
